<template>
  <div class="detail-page">
    <div class="page-header">
      <div class="title-box">
        <el-button class="back-button" icon="el-icon-back" @click="goback">返回</el-button>
        <div class="page-title">换届详情</div>
      </div>
      <div>
        <el-button type="primary" class="back-button" @click="detailToEdit">编辑</el-button>
      </div>
    </div>
    <div class="page-body">
      <div class="titleStyle">
        <span>选举信息</span>
      </div>
      <el-descriptions direction="vertical" :column="2">
        <el-descriptions-item label="党组织名称">{{ form.partyOrgName }}</el-descriptions-item>
        <el-descriptions-item label="当前届期">{{ form.currentTerm }}</el-descriptions-item>
        <el-descriptions-item :span="2" label="选举方式">{{ typeList[form.electionMethod] }}</el-descriptions-item>
        <el-descriptions-item label="选举应到人数">{{ form.presentPeopleNum }}</el-descriptions-item>
        <el-descriptions-item label="选举实到人数">{{ form.actuallyPresentPeopleNum }}</el-descriptions-item>
        <el-descriptions-item label="任期开始时间">{{ form.termStartDate }}</el-descriptions-item>
        <el-descriptions-item label="任期结束时间">{{ form.termEndDate }}</el-descriptions-item>
      </el-descriptions>
      <div class="titleStyle">
        <span>得票情况</span>
      </div>
      <el-table
        :data="tableData"
      >
        <el-table-column align="center" label="序号" type="index" width="80" />
        <el-table-column prop="partyMemberName" align="center" label="党员姓名" />
        <el-table-column prop="positionLevel" align="center" label="职位级别" />
        <el-table-column prop="approve" align="center" label="赞成" />
        <el-table-column prop="isReject" align="center" label="反对" />
        <el-table-column prop="abstention" align="center" label="弃权" />
        <el-table-column prop="elected" align="center" label="是否当选">
          <template slot-scope="scope">
            {{ electedList[scope.row.elected] }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      form: {},
      tableData: [],
      typeList: ['不记名投票', '记名投票，线下投票'],
      electedList: ['是', '否']
    }
  },
  methods: {
    init (row) {
      this.form = { ...row }
      this.tableData = row.memberInfoVOList || []
    },
    goback () {
      this.$emit('goback')
    },
    detailToEdit () {
      this.$emit('detailToEdit', this.form)
    }
  }
}
</script>
<style scoped lang="scss">
  .page-header {
    display: flex;
    height: 60px;
    align-items: center;
    border-bottom: 1px solid #ddd;
    justify-content: space-between;
    .title-box {
      display: flex;
      height: 60px;
      align-items: center;
    }
    .back-button {
      margin-right: 16px;
    }
    .page-title {
      font-size: 18px;
      font-weight: 600;
    }
  }
  .page-body {
    height: calc(100vh - 130px);
    overflow-y: auto;
    position: relative;
    .titleStyle {
      font-weight: 600;
      height: 35px;
      line-height: 35px;
      padding-left: 10px;
      padding-right: 10px;
      margin-bottom: 8px;
      background-color: #d8eff9;
      display: flex;
      justify-content: space-between;
    }
  }
</style>
